<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('SAP入库单单据明细')"/>
    <style>
        [v-cloak] {
            display: none
        }
        .deer-key {
            width: 95px;
        }
        .el-table--scrollable-y .el-table__body-wrapper::-webkit-scrollbar {
            display: none;
        }
    </style>
</head>
<body>
<div class="container-div">
    <a class="btn btn-default" @click="closeModal()">
        <i class="fa fa-reply"></i> 返回
    </a>
    <!--    <a class="btn btn-info" @click="detailExcel()">-->
    <!--        <i class="fa fa-download"></i> 导出-->
    <!--    </a>-->
    <el-row class="deer-panel">
        <span style="color: #409EFF">SAP入库单</span>
        <el-divider style="margin-top: 10px"></el-divider>
        <el-col :span="8">
            <div class="deer-ky">
                <div class="deer-key">质量装换单号：</div>
                <div class="deer-value" v-cloak>{{billInSapInfo.stateNo}}</div>
            </div>
        </el-col>
        <el-col :span="8">
            <div class="deer-ky">
                <div class="deer-key">创建人：</div>
                <div class="deer-value" v-cloak>{{billInSapInfo.createName}}</div>
            </div>
        </el-col>
        <el-col :span="8">
            <div class="deer-ky">
                <div class="deer-key">创建时间：</div>
                <div class="deer-value" v-cloak>{{billInSapInfo.createTime}}</div>
            </div>
        </el-col>
    </el-row>

    <el-row :gutter="20">
        <el-col :span="24">
            <el-tabs type="border-card" class="deer-panel" style="margin-top: 15px;padding-top: 0">
                <el-tab-pane>
                    <span slot="label"><i class="el-icon-date"></i> 单据明细</span>
                    <el-table :data="item.list" border stripe height="260">
                        <el-table-column prop="itemCode" label="物料编码" align="center" width="200"></el-table-column>
                        <el-table-column prop="itemName" label="物料描述" align="center" width="200"></el-table-column>
                        <el-table-column prop="sort" label="物料类型" align="center" width="120">
                            <template slot-scope="scope">
                                <span v-if="scope.row.sort ==1">
                                    钢材
                                </span>
                                <span v-if="scope.row.sort ==2">
                                    铜材
                                </span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="unit" label="单位" align="center" width="55"></el-table-column>
                        <el-table-column prop="billInState" label="新质量" align="center">
                            <template slot-scope="scope">
                                <span v-if="scope.row.billInState ==1">
                                    合格
                                </span>
                                <span v-if="scope.row.billInState ==2">
                                    待检
                                </span>
                                <span v-if="scope.row.billInState ==3">
                                    不合格
                                </span>
                                <span v-if="scope.row.billInState ==4">
                                    异常
                                </span>
                                <span v-if="scope.row.billInState ==5">
                                    试作品
                                </span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="oldBillInState" label="旧质量" align="center">
                            <template slot-scope="scope">
                                <span v-if="scope.row.oldBillInState ==1">
                                    合格
                                </span>
                                <span v-if="scope.row.oldBillInState ==2">
                                    待检
                                </span>
                                <span v-if="scope.row.oldBillInState ==3">
                                    不合格
                                </span>
                                <span v-if="scope.row.oldBillInState ==4">
                                    异常
                                </span>
                                <span v-if="scope.row.oldBillInState ==5">
                                    试作品
                                </span>
                            </template>
                        </el-table-column>
                    </el-table>
                    <el-pagination
                            @current-change="chengCurrentPage"
                            :current-page="item.currentPage"
                            :page-size="item.pageSize"
                            layout="prev, pager, next"
                            :total="item.total">
                    </el-pagination>
                </el-tab-pane>
            </el-tabs>
        </el-col>
    </el-row>
</div>

<div th:include="include::footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "in/boxItem";

    var stateId = parseInt(localStorage.getItem('/IngotIocus'));

    var vue = new Vue({
        el: '.container-div',
        data: {
            billInSapInfo: {},
            item: {
                currentPage: 1,
                pageSize: 4,
                total: '',
                list: []
            }
        },
        methods: {
            //分页
            chengCurrentPage: function(currentPage){
                this.item.currentPage = currentPage;
                this.getDetails(null);
            },
            //关闭此页面
            closeModal(){
                var index = parent.layer.getFrameIndex(window.name);
                parent.layer.close(index);
            },
            //SAP收货单信息
            getBillInSapInfo(){
                var that = this;
                $.ajax({
                    cache: true,
                    type: "POST",
                    url: prefix + '/findStateById',
                    data: {
                        stateId: stateId
                    },
                    async: false,
                    error: function(request){
                        $.modal.alertError("系统错误");
                    },
                    success: function(data){
                        if(data.createTime != null){
                            data.createTime = data.createTime.slice(0, 19);
                        }
                        that.billInSapInfo = data;
                    }
                });
            },
            //SAP收货单明细
            getDetails(){
                var that = this;
                $.ajax({
                    url: prefix + "/findListdetailById",
                    type: "POST",
                    data: {
                        stateId: stateId
                    },
                    error: function(request){
                        $.modal.alertError("系统错误");
                    },
                    success: function(data){
                        var msg = data.rows;
                        that.item.list = msg;
                        that.item.total = data.total;
                    }
                })
            },
        },
        created(){
            this.getBillInSapInfo();
            this.getDetails();
        }
    })
</script>
</body>
</html>
